#!/home/y/bin/perl

use FindBin qw/$Bin/;
use lib qw(lib ../lib);
use Test::More qw(no_plan);
use Farsail::Util qw(:all);
use Farsail;
use Log::Log4perl qw/:easy/;
# Log::Log4perl->easy_init($DEBUG);

$ENV{FARSAILDIR} ||= "$Bin/../conf";
use DBI;
use_ok("Farsail::DBLoader");

my $farsail = Farsail->instance;
$farsail->easy_init();
$farsail->load_modules("Farsail::DBLoader");

if ( 0 ) {
    Farsail::DBLoader->load(
        {
            database => 'demo2',
            table => 'authors',
        },
        {
            database => 'demo',
            table => 'authors',
        }
    );
    ok(1, 'load data from table');
}

if ( 0 ) {
    Farsail::DBLoader->load(
        {
            database => 'demo2',
            query => 'select * from authors where id < 5',
        },
        {
            database => 'demo',
            table => 'authors',
        }
    );
    ok(1, 'load data from sql');
}

if ( 0 ) {
    Farsail::DBLoader->load(
        expand_file("../data/authors.tsv", $farsail->config->rootdir),
        {
            database => 'demo',
            table => 'authors',
        }
    );
    ok(1, 'load data from file');
}

if ( 0 ) {
    Farsail::DBLoader->load(
        # expand_file("../data/authors.tsv", $farsail->config->rootdir),
        { database => 'demo2',
          table => 'authors' },
        { database => 'devdp1',
          table => 'authors',
          schema => expand_file("../data/authors.ctl", $farsail->config->rootdir),
      }
    );
    ok(1, 'load data to oracle from pg');
}

if ( 1 ) {
    Farsail::DBLoader->load(
        expand_file("../data/authors.tsv", $farsail->config->rootdir),
        { database => 'devdp1',
          table => 'authors',
          schema => expand_file("../data/authors.ctl", $farsail->config->rootdir),
      }
    );
    ok(1, 'load data to oracle from pg');
}
